package com.ruoyi.teach.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.constant.BusinessTypeEnum;
import com.ruoyi.teach.domain.TeachStudentTag;
import com.ruoyi.teach.service.ITeachStudentTagService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生标签Controller
 *
 * @author ruoyi
 * @date 2025-05-21
 */
@RestController
@RequestMapping("/studentTag/tag")
public class TeachStudentTagController extends BaseController
{
    @Autowired
    private ITeachStudentTagService teachStudentTagService;

    /**
     * 查询学生标签列表
     */
    @PreAuthorize("@ss.hasPermi('studenTag:tag:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeachStudentTag teachStudentTag)
    {
        startPage();
        List<TeachStudentTag> list = teachStudentTagService.selectTeachStudentTagList(teachStudentTag);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('studenTag:tag:list')")
    @GetMapping("/tagList/{studentId}")
    public TableDataInfo tagList(@PathVariable("studentId") long studentId)
    {
        List<TeachStudentTag> list = teachStudentTagService.selectTeachStudentTagList(studentId);
        return getDataTable(list);
    }

    /**
     * 导出学生标签列表
     */
    @PreAuthorize("@ss.hasPermi('studenTag:tag:export')")
    @Log(title = "学生标签", businessType = BusinessTypeEnum.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeachStudentTag teachStudentTag)
    {
        List<TeachStudentTag> list = teachStudentTagService.selectTeachStudentTagList(teachStudentTag);
        ExcelUtil<TeachStudentTag> util = new ExcelUtil<TeachStudentTag>(TeachStudentTag.class);
        util.exportExcel(response, list, "学生标签数据");
    }

    /**
     * 获取学生标签详细信息
     */
    @PreAuthorize("@ss.hasPermi('studenTag:tag:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(teachStudentTagService.selectTeachStudentTagById(id));
    }

    /**
     * 新增学生标签
     */
    @PreAuthorize("@ss.hasPermi('studenTag:tag:add')")
    @Log(title = "学生标签", businessType = BusinessTypeEnum.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeachStudentTag teachStudentTag)
    {
        return toAjax(teachStudentTagService.insertTeachStudentTag(teachStudentTag));
    }

    /**
     * 修改学生标签
     */
    @PreAuthorize("@ss.hasPermi('studenTag:tag:edit')")
    @Log(title = "学生标签", businessType = BusinessTypeEnum.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeachStudentTag teachStudentTag)
    {
        return toAjax(teachStudentTagService.updateTeachStudentTag(teachStudentTag));
    }

    /**
     * 删除学生标签
     */
    @PreAuthorize("@ss.hasPermi('studenTag:tag:remove')")
    @Log(title = "学生标签", businessType = BusinessTypeEnum.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(teachStudentTagService.deleteTeachStudentTagByIds(ids));
    }

    /**
     * 删除学生标签
     */
    @PreAuthorize("@ss.hasPermi('studenTag:tag:remove')")
    @Log(title = "学生标签", businessType = BusinessTypeEnum.DELETE)
    @DeleteMapping("tagId/{id}")
    public AjaxResult remove(@PathVariable String id)
    {
        return toAjax(teachStudentTagService.deleteTeachStudentTagByTagId(id));
    }
}
